package yanivosher.aiproject;

import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		if (args.length > 1) {
			InputParser.parseFile(args[1]);
		}
		else {
			File file = new File("Input.txt");
			String s = file.getAbsolutePath();
			if(file.exists())
			{
				System.out.print(s);
			}
			InputParser.parseFile(s);
		}
		
		System.out.println(Environment.getInstance().toString());
		
		Scanner sc = new Scanner(System.in);

		System.out.println("Insert game type:\n1: Human Agent\n2: MinMax Agent\n3: NonZero Agent\n4: MaxMax Agent");
	    int type = sc.nextInt();
	    
	    for (int i = 0; i < 2; i++) {
  
			System.out.print("Insert Agent Source for agent" + i + ":");
		    String source = sc.next();

			System.out.print("Insert Agent Destination for agent" + i + ":");
		    String destination = sc.next();
		    
			switch (type) {
			case 1:
				Environment.getInstance().agents.add(new HumanAgent(
						Environment.getInstance().graph.getVertexById(source), 
						Environment.getInstance().graph.getVertexById(destination),
						i));
				break;
			case 2:
				Environment.getInstance().agents.add(new GameSearchMinmaxAgent(
						Environment.getInstance().graph.getVertexById(source), 
						Environment.getInstance().graph.getVertexById(destination),
						i));
				break;
			case 3:
				Environment.getInstance().agents.add(new GameSearchNonZeroSumAgent(
						Environment.getInstance().graph.getVertexById(source), 
						Environment.getInstance().graph.getVertexById(destination),
						i));
				break;
			case 4:
				Environment.getInstance().agents.add(new GameSearchMaxMaxSumAgent(
						Environment.getInstance().graph.getVertexById(source), 
						Environment.getInstance().graph.getVertexById(destination),
						i));
				break;
			default:
				break;
			}
		} 

	    //sc.close();
		System.out.println(Environment.getInstance().toString());

		System.out.println("Simulating!");
		Simulator.simulateWorld();
	}

}
